Movie controller components allow you to create an action filter function in your application. The component calls your action filter function whenever an action occurs in the control. (An action is an integer constant used by the movie controller component.) You can then customize the behavior of the control or simply monitor user actions. You establish an action filter function by calling the MCSetActionFilterWithRefCon function, which is described on MCSetActionFilterWithRefCon .
The sample code in Listing 2-2 demonstrates the use of an action filter function. This filter function resizes the window whenever the user hides the controller. Therefore, this sample function handles the mcActionControllerSizeChanged action. Your application should include a similar action filter function so that you can determine when the user resizes the controller. This function supports only attached controllers.
Listing 2 Using a movie controller filter function
pascal Boolean myMCActionFilter ( MovieController mc,
short* Action, long* params);
{
RgnHandle controllerRgn;
Rect controllerBox;
WindowPtr movieWindow;
switch (*Action) {
case mcActionControllerSizeChanged:
/* size of controller/movie has changed */
movieWindow = (WindowPtr)MCGetControllerPort(mc);
controllerRgn = MCGetWindowRgn(mc, movieWindow);
if (controllerRgn != nil) {
controllerBox = (**controllerRgn).rgnBBox;
DisposeRgn (controllerRgn);
SizeWindow (movieWindow, controllerBox.right,
controllerBox.bottom, true);
}
break;
}
return false;
}